package com.inspur.edp.common.type.mgr;

import com.inspur.edp.common.type.Type;
import com.inspur.edp.common.type.TypeRefer;
import com.inspur.edp.common.type.exception.TypeException;
import com.inspur.edp.common.type.spi.TypeProviderFactory;
import com.inspur.edp.common.type.spi.TypeResourceProvider;

/**
 * @author lizhaorui
 * @date 2025/10/14
 * @description
 */
public class TypeMgr {

    public static Type getType(TypeRefer typeRefer) {
        TypeResourceProvider provider = TypeProviderFactory.getProvider(typeRefer.getSource());
        if (provider != null) {
            Type type = provider.getType(typeRefer.getTypeId());
            return type;
        } else {
            throw new TypeException("not find type provider " + typeRefer.getSource());
        }
    }
}

